#include "SQLVariantRefExpr.h"
#include "../../visitor/SQLASTVisitor.h"

SETCALSS(SQLVariantRefExpr);

SQLVariantRefExpr::SQLVariantRefExpr(string_ptr theName)
    : name(theName), global(BOOL::FALSE), index(-1)
{
  // this.name = name;
}
SQLVariantRefExpr::SQLVariantRefExpr(const char *theName)
    : name(make_string_ptr(theName)), global(BOOL::FALSE), index(-1)
{
  // this.name = name;
}

SQLVariantRefExpr::SQLVariantRefExpr(string_ptr theName, BOOL_ptr theGlobal) : name(theName), global(theGlobal), index(-1)
{
  // this.name = name;
  // this.global = global;
}
SQLVariantRefExpr::SQLVariantRefExpr(string_ptr theName, BOOL_ptr theGlobal, BOOL_ptr theSession) : name(theName), global(theGlobal), session(theSession)
{
  // this.name = name;
  // this.global = global;
  // this.session = session;
}
SQLVariantRefExpr::~SQLVariantRefExpr()
{
}

SQLVariantRefExpr::SQLVariantRefExpr()
{
}

SQLVariantRefExpr::SQLVariantRefExpr(string_ptr name, SQLObject_ptr parent)
{
  this->name = name;
  this->parent = parent;
}

int SQLVariantRefExpr::getIndex()
{
  return index;
}

void SQLVariantRefExpr::setIndex(int theIndex)
{
  index = theIndex;
}

string_ptr SQLVariantRefExpr::getName()
{
  return name;
}

void SQLVariantRefExpr::setName(string_ptr theName)
{
  name = theName;
}

void SQLVariantRefExpr::output(std::stringstream *  buf)
{
  (*buf)<<*name;
  // buf.append(name);
}

void SQLVariantRefExpr::accept0(SQLASTVisitor_ptr visitor)
{
  visitor->visit(SharedObject(SQLVariantRefExpr));

  visitor->endVisit(SharedObject(SQLVariantRefExpr));
}

// int SQLVariantRefExpr::hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + ((name == null) ? 0 : name.hashCode());
// return result;
//}

// BOOL_ptr SQLVariantRefExpr::equals(Object obj) {
// if (this == obj) {
// return BOOL::TRUE;
//}
// if (obj == null) {
// return BOOL::FALSE;
//}
// if (!(obj instanceof SQLVariantRefExpr)) {
// return BOOL::FALSE;
//}
// SQLVariantRefExpr other = (SQLVariantRefExpr) obj;
// if (name == null) {
// if (other.name != null) {
// return BOOL::FALSE;
//}
//} else if (!name.equals(other.name)) {
// return BOOL::FALSE;
//}
// return BOOL::TRUE;
//}

BOOL_ptr SQLVariantRefExpr::isGlobal()
{
  return global;
}

void SQLVariantRefExpr::setGlobal(BOOL_ptr theGlobal)
{
  global = theGlobal;
}
